Page({
  data: {
    LoginNo: "",
    Password: ""
  },
  onLoad() {},
  login(){
    
    getApp().req({
      url: "/auth",
      type: "POST",
      data: {
        LoginNo: this.data.LoginNo,
        Password: this.data.Password
      },
      cb(res){
        console.log(res);
        if(res.data.token){
          getApp().loginSuccess({LoginNo: this.data.LoginNo,Password: this.data.Password},res.data)
          dd.showToast({
            type: 'success',
            content: '登录成功',
            success(){
              dd.switchTab({
                url: "/pages/index/index"
              })
            }
          });
        }
      },
      fail(res){
        console.log(res);
        if(res.status != 500){
          dd.alert({content: res.data});
        }
      }
    })
  },
  changeValue(e){
    var aftdata = {}
    if(e.target.dataset.parent){
      aftdata = this.data[e.target.dataset.parent]
    }
    aftdata[e.target.dataset.key] = e.detail.value
    this.setData(aftdata)
  }
});
